﻿
using System;
using System.Diagnostics;
namespace NLite
{
    /// <summary>
    /// 监听器接口
    /// </summary>
    /// <remarks>充当观察者模式中的抽象观察者角色</remarks>
    public interface IListener
    {

    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TEnum"></typeparam>
    public interface IListener<TEnum>
    {
        /// <summary>
        /// 
        /// </summary>
        TEnum Type { get; }
    }

    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class Listener : MarshalByRefObject, IListener
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override object InitializeLifetimeService()
        {
            return null;
        }
    }

    /// <summary>
    /// 
    /// </summary>
    /// <typeparam name="TEnum"></typeparam>
    [Serializable]
    public class Listener<TEnum> : Listener
    {
        /// <summary>
        /// 
        /// </summary>
        public TEnum Type { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="type"></param>
        protected Listener(TEnum type)
        {
            Trace.Assert(type != null, "type == null");
            //Trace.Assert(Enum.IsDefined(type.GetType(), type), "type does not Enum type");
            Type = type;
        }
    }
}
